package stringExertises;

import java.util.Scanner;

/**
 * @author: bamboo_shoot
 * @date: 20/2/3 17:26
 * @description: 遍历字符串
 * 需求：键盘录入一个字符串，使用程序实现在控制台遍历该字符串
 */
public class TraverseCharacter {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一串字符");
        String next = sc.nextLine();
//        方法一
       /* char[] chars = next.toCharArray();
        for (int i = 0; i < chars.length; i++) {
            System.out.print(chars[i] + ",");
        }*/
//       方法二
        for (int i = 0; i < next.length(); i++) {
            System.out.print(next.charAt(i)+" ");
        }
    }
}
